// ****************************************************************************************************
// Uso: $("#columncentral").html( VerObjetoJavaScript ( object ) );
function VerObjetoJavaScript(object) {
	var output = '';
	for (property in object) {
		output += '<b>' + property + '</b> : ' + object[property] + '; <br />';
	}
	return output;
}

// ****************************************************************************************************
function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(
			/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
	// alert( pattern.test(emailAddress) );
	return pattern.test(emailAddress);
}

// ****************************************************************************************************
/*
 * Password Validator 0.1 (c) 2007 Steven Levithan <stevenlevithan.com> MIT
 * License
 */

function validatePassword(pw, options) {

	return true;

	// default options (allows any password)
	var o = {
		lower : 0,
		upper : 0,
		alpha : 0, /* lower + upper */
		numeric : 0,
		special : 0,
		length : [ 0, Infinity ],
		custom : [ /* regexes and/or functions */],
		badWords : [],
		badSequenceLength : 0,
		noQwertySequences : false,
		noSequential : false
	};

	for ( var property in options)
		o[property] = options[property];

	$("#INDEX_FORM_NEW_USER_progressbar").find(".ui-progressbar-value").css({
		"background" : '#e4244d'
	});
	$("#INDEX_FORM_NEW_USER_progressbar").progressbar({
		value : 0
	});

	var re = {
		lower : /[a-z]/g,
		upper : /[A-Z]/g,
		alpha : /[A-Z]/gi,
		numeric : /[0-9]/g,
		special : /[\W_]/g
	}, rule, i;

	// enforce min/max length
	if (pw.length < o.length[0] || pw.length > o.length[1])
		return false;

	$("#INDEX_FORM_NEW_USER_progressbar").find(".ui-progressbar-value").css({
		"background" : '#e4244d'
	});
	$("#INDEX_FORM_NEW_USER_progressbar").progressbar({
		value : 30
	});

	// enforce lower/upper/alpha/numeric/special rules
	for (rule in re) {
		if ((pw.match(re[rule]) || []).length < o[rule])
			return false;
	}

	$("#INDEX_FORM_NEW_USER_progressbar").find(".ui-progressbar-value").css({
		"background" : '#fbd439'
	});
	$("#INDEX_FORM_NEW_USER_progressbar").progressbar({
		value : 40
	});

	// enforce word ban (case insensitive)
	for (i = 0; i < o.badWords.length; i++) {
		if (pw.toLowerCase().indexOf(o.badWords[i].toLowerCase()) > -1)
			return false;
	}

	$("#INDEX_FORM_NEW_USER_progressbar").find(".ui-progressbar-value").css({
		"background" : '#fbd439'
	});
	$("#INDEX_FORM_NEW_USER_progressbar").progressbar({
		value : 60
	});

	// enforce the no sequential, identical characters rule
	if (o.noSequential && /([\S\s])\1/.test(pw))
		return false;

	$("#INDEX_FORM_NEW_USER_progressbar").find(".ui-progressbar-value").css({
		"background" : '#fbd439'
	});
	$("#INDEX_FORM_NEW_USER_progressbar").progressbar({
		value : 80
	});

	// enforce alphanumeric/qwerty sequence ban rules
	if (o.badSequenceLength) {
		var lower = "abcdefghijklmnopqrstuvwxyz", upper = lower.toUpperCase(), numbers = "0123456789", qwerty = "qwertyuiopasdfghjklzxcvbnm", start = o.badSequenceLength - 1, seq = "_"
				+ pw.slice(0, start);
		for (i = start; i < pw.length; i++) {
			seq = seq.slice(1) + pw.charAt(i);
			if (lower.indexOf(seq) > -1 || upper.indexOf(seq) > -1
					|| numbers.indexOf(seq) > -1
					|| (o.noQwertySequences && qwerty.indexOf(seq) > -1)) {
				return false;
			}
		}
	}

	$("#INDEX_FORM_NEW_USER_progressbar").find(".ui-progressbar-value").css({
		"background" : '#fbd439'
	});
	$("#INDEX_FORM_NEW_USER_progressbar").progressbar({
		value : 90
	});

	// enforce custom regex/function rules
	for (i = 0; i < o.custom.length; i++) {
		rule = o.custom[i];
		if (rule instanceof RegExp) {
			if (!rule.test(pw))
				return false;
		} else if (rule instanceof Function) {
			if (!rule(pw))
				return false;
		}
	}

	$("#INDEX_FORM_NEW_USER_progressbar").find(".ui-progressbar-value").css({
		"background" : '#74fd14'
	});
	$("#INDEX_FORM_NEW_USER_progressbar").progressbar({
		value : 100
	});

	// great success!
	return true;
}
